package com.concerneyes.mine.adapter;

import android.content.Context;
import android.content.res.Resources;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.concerneyes.CEApp;
import com.concerneyes.R;
import com.concerneyes.mine.model.MyExtensionModel;

import java.util.List;

import common.BASE_Adapter;
import util.ImageUtil;
import view.RoundImageView;

/**
 * Created by Administrator on 2017/6/21 0021.
 */

public class MyExtensionAdapter extends BASE_Adapter<MyExtensionModel> {
    private Context context;
    private List<MyExtensionModel> data;

    public MyExtensionAdapter(Context context, List<MyExtensionModel> data) {
        super(context, data);
        this.context = context;
        this.data = data;
    }

    @Override
    public View createView(LayoutInflater inflater, int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            holder = new ViewHolder();
            convertView = inflater.inflate(R.layout.item_extention, null);
            holder.ivExtension = (RoundImageView) convertView.findViewById(R.id.iv_me_icon);
            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }
        holder.ivExtension.setRoundDegree(10);
        DisplayMetrics dm = context.getResources().getDisplayMetrics();
        double heightPixels = dm.heightPixels * 0.28;
        RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(-1,(int)heightPixels);
        holder.ivExtension.setLayoutParams(params);

        ImageUtil.glideloadImage(CEApp.getResLink(data.get(position).getCover()), holder.ivExtension, ImageUtil.DEFAULT_DRAWABLE);
        return convertView;
    }

    class ViewHolder {
        RoundImageView ivExtension;
    }
}
